﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Security;

namespace GMS.BIZ
{
    public class User
    {
        /*property:
         *  string userID;         
         *  arraylist roleList; 所有该用户存在的角色 
         */
        private string userID;
        public string UserID
        {
            get { return userID; }
            set { userID = value; }
        }
        private ArrayList roleList;
        public ArrayList RoleList
        {
            get { return roleList; }
            set { roleList = value; }
        }
        

        public User()
        {
            ArrayList newArrayList = new ArrayList();
            this.roleList = null;
            this.roleList = newArrayList;
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="newPassword">新密码</param>
        public string ChangePassword(string newPassword)
        {
            GMS.ORM.DAL.SLogin optLogin = new GMS.ORM.DAL.SLogin();
            GMS.ORM.Model.SLogin myLogin = new GMS.ORM.Model.SLogin();
            myLogin = optLogin.GetModel(this.userID);
            //更改新的密码
            myLogin.password = FormsAuthentication.HashPasswordForStoringInConfigFile(newPassword, "MD5").ToLower();
            bool ok = optLogin.Update(myLogin);
            if (!ok) return ErrorMessage.DBOptError;
            else return ErrorMessage.OK;

        }
    }
}
